using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Rensoft.CRM.Client.AccountsAPI;
using Rensoft.CRM.Client.Editors;

namespace Rensoft.CRM.Client.ItemViews
{
    public partial class ServiceView : Rensoft.CRM.Client.ItemViews.BaseView
    {
        private Service[] serviceArray;

        protected Service[] ServiceArray
        {
            get { return serviceArray; }
            set { serviceArray = value; }
        }

        /// <summary>
        /// Parameterless constructor for forms designer.
        /// </summary>
        public ServiceView() : base()
        {
            InitializeComponent();
        }

        public ServiceView(Program program)
            : base(program)
        {
            InitializeComponent();
        }

        protected override void LoadComplete(RunWorkerCompletedEventArgs e)
        {
            if (serviceArray != null)
            {
                ItemsListView.VirtualListSize = serviceArray.Length;
                ItemsListView.VirtualMode = true;
                UpdateItemCount(serviceArray.Length);
            }
            else
            {
                // No items downloaded, so count is 0.
                UpdateItemCount(0);
            }

            base.LoadComplete(e);
        }

        protected override void OnEnter(EventArgs e)
        {
            if (serviceArray != null)
            {
                UpdateItemCount(serviceArray.Length);
            }
            else
            {
                // No items downloaded, so count is 0.
                UpdateItemCount(0);
            }

            base.OnEnter(e);
        }

        internal override BaseEditor GetEditor()
        {
            return new AccountEditor(Program);
        }
    }
}

